// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Eggman Window Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// Aliases
private alias 42 : TYPE_EGGMANWINDOW


// Static Values

// Tables

event ObjectMain
end event


event ObjectDraw
	switch object.animation
	case 0
		DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
		break
	case 1
		object.animationTimer++
		if object.animationTimer == 4
			object.animationTimer = 0
			object.frame++
			if object.frame == 4
				object.animation = 2
			end if
		end if
		DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
		break
	case 2
		DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)
		break
	case 3
		temp0 = object.animationTimer
		temp0 &= 15
		temp0 >>= 3
		temp0 += 5
		object.animationTimer++
		if object.animationTimer == 50
			object.animationTimer = 0
			if object[0].animation != ANI_DYING
				object.animation = 2
			end if
		end if
		DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
		break
	case 4
		temp0 = object.animationTimer
		object.animationTimer++
		if object.animationTimer == 50
			object.animationTimer = 0
			object.animation = 2
		end if
		DrawSpriteFX(7, FX_FLIP, object.xpos, object.ypos)
		break
	case 5
		object.animationTimer++
		if object.animationTimer == 4
			object.animationTimer = 0
			object.frame--
			if object.frame == 0
				object.animation = 0
			end if
		end if
		DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
		break
	end switch
end event


event ObjectStartup
		if saveRAM[495] == 0
			LoadSpriteSheet("DEZ/Objects.gif")
			SpriteFrame(-16, -12, 32, 24, 133, 114)	//Closes
			SpriteFrame(-16, -12, 32, 24, 100, 114)	//Opening I
			SpriteFrame(-16, -12, 32, 24, 67, 114)	//Opening II
			SpriteFrame(-16, -12, 32, 24, 34, 114)	//Opening III
			SpriteFrame(-16, -12, 32, 24, 1, 114)	//Open
			SpriteFrame(-16, -12, 32, 24, 166, 114)	//Laught I
			SpriteFrame(-16, -12, 32, 24, 199, 114)	//Laught II
			SpriteFrame(-16, -12, 32, 24, 232, 114)	//Hit
		else
			LoadSpriteSheet("DEZ/Objects.gif")
			SpriteFrame(-16, -12, 32, 24, 133, 114)	//Closes
			SpriteFrame(-16, -12, 32, 24, 100, 114)	//Opening I
			SpriteFrame(-16, -12, 32, 24, 67, 139)	//Opening II Robo
			SpriteFrame(-16, -12, 32, 24, 34, 139)	//Opening III Robo
			SpriteFrame(-16, -12, 32, 24, 1, 139)	//Open Robo
			SpriteFrame(-16, -12, 32, 24, 100, 139)	//Laught I Robo
			SpriteFrame(-16, -12, 32, 24, 133, 139)	//Laught II Robo
			SpriteFrame(-16, -12, 32, 24, 166, 139)	//Hit Robo
		endif
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
